package com.zheng.springcloud.service;

import com.zheng.springcloud.pojo.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.ArrayList;

/**
 * @author lenovo
 */
@Component
public class DeptFallback implements FallbackFactory {
    @Override
    public Object create(Throwable throwable) {
        return new DeptService() {
            @Override
            public boolean addDept(Dept dept) {
                return false;
            }

            @Override
            public Dept get(int id) {
                return new Dept().setDeptId(-1).setDeptName("服务器繁忙，请稍候重试！").setDeptDatabase("数据库繁忙！");
            }

            @Override
            public ArrayList<Dept> select() {
                ArrayList<Dept> list = new ArrayList<>();
                list.add(new Dept().setDeptId(-1).setDeptName("服务器繁忙，请稍候重试！").setDeptDatabase("数据库繁忙！"));
                return list;
            }
        };
    }
}
